from flask import Flask
from flask_cors import CORS
from config.config import config
from app.extensions import db

def create_app(config_name='default'):
    app = Flask(__name__)
    app.config.from_object(config[config_name])

    db.init_app(app)
    CORS(app)

    from app.api import api_bp
    app.register_blueprint(api_bp, url_prefix='/api')

    return app